Chargement des librairies

Attention select de mass (dépendance de mixOmics) prend le pas sur dplyr

## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.3     ✓ purrr   0.3.4
## ✓ tibble  3.1.1     ✓ dplyr   1.0.5
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
## Loading required package: MASS
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select
## Loading required package: lattice
## 
## Loaded mixOmics 6.14.1
## Thank you for using mixOmics!
## Tutorials: http://mixomics.org
## Bookdown vignette: https://mixomicsteam.github.io/Bookdown
## Questions, issues: Follow the prompts at http://mixomics.org/contact-us
## Cite us:  citation('mixOmics')
## 
## Attaching package: 'mixOmics'
## The following object is masked from 'package:purrr':
## 
##     map
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa

Chargement des données brutes

chemin <- "Raw_brut/"

#Echantillons
Sample <- read.csv2(paste0(chemin,"MI_Covariates.csv"))
Corres_var <- read.csv2(paste0(chemin,"MI_Covariates_corresp.csv"))
Corres_ID <- read.csv2(paste0(chemin,"Mb_Info_seq.csv"))

#Métabolites
NMR_CPMG <- read.csv2(paste0(chemin,"NMR_CPMG.csv"))
NMR_NOESY <- read.csv2(paste0(chemin,"NMR_NOESY1D.csv"))
List_cplte_CPMG <- read.csv2(paste0(chemin,"NMR_BUCKET_CPMG_LIST_assigned.csv"))
List_cplte_NOESY <- read.csv2(paste0(chemin,"NMR_BUCKET_NOESY_LIST_assigned.csv"))
List_CPMG <- read.csv2(paste0(chemin,"List_NMR.csv"))
List_NOESY <- read.csv2(paste0(chemin,"List_NOESY.csv"))


## Homogénéisation des noms de variables
##Attention package mass possède un select qui annule celui de dplyr
Sample_ID <- left_join(Sample,Corres_ID,by=c("DonorID"="DonorId")) %>% 
  relocate("Echantillon", .before = "DonorID")  %>% 
  dplyr::select(-"SeqDepth",-"DonorID")
rownames(Sample_ID) = Sample_ID$Echantillon

#Met la variable AGE en catégorie non hierarchisé et transformation en factor
Sample_ID <- Sample_ID %>% 
  dplyr::select(-"Echantillon") %>% 
  mutate(age = factor(AGE, levels = c(1, 2, 3, 4, 5), labels = c("[20-29]", "[30-39]", "[40-49]", "[50-59]", "[60-69]"))) %>% 
  mutate(SEX = factor(SEX)) 
Sample_ID$tabac <- factor(Sample_ID$tabac)



CPMG <- left_join(NMR_CPMG,Corres_ID,by=c("DonnorID"="DonorId")) %>% 
  relocate("Echantillon", .before = "DonnorID") %>% 
  dplyr::select(-c("DonnorID","Sample_type","VagueManip","Date","Spectre2","Exp"))
rownames(CPMG) = CPMG$Echantillon
CPMG <- CPMG %>% 
  dplyr::select(-Echantillon)

NOESY <- left_join(NMR_NOESY,Corres_ID,by=c("DonnorID"="DonorId")) %>% 
  relocate("Echantillon", .before = "DonnorID") %>% 
  dplyr::select(-c("DonnorID","Spectre2","Exp","Sample_type","VagueManip","CV_Grps","CV_Grps6","CV_Grps7","CV_Grps8","CV_Grps9"))
rownames(NOESY) = NOESY$Echantillon
NOESY <- NOESY %>% 
  dplyr::select(-Echantillon)

# Passage en matrice
Noesy <- as.matrix(NOESY)
Cpmg <- as.matrix(CPMG)




# ?mixOmics
# #selection des métabolites d'interêts. Voir pour transposer et ne selectionner que certaines col avec métabo nommés 
# List_CPMG1 <- t(List_CPMG)
# colnames(List_CPMG1) = List_CPMG1[1,]
# List_CPMG2 <-  t(List_CPMG1[3,])
# List_CPMG2 <- t(List_CPMG2)

Création du Dataset mixomics

ncomp correspond: The number of components to include in the model for each block (does not necessarily need to take the same value for each block). Je ne sais pas. J’ai mis 3 pour le tabac Ne fonctionne pas pour CPMG

## a Partial Least Squares - Discriminant Analysis is being performed (PLS-DA)
## a Partial Least Squares - Discriminant Analysis is being performed (PLS-DA)

Graph issus du Package mixOmics

## **Results for the Principal Component Analysis (PCA)**
## The analysis was performed on 846 individuals, described by 215 variables
## *The results are available in the following objects:
## 
##    name               description                          
## 1  "$eig"             "eigenvalues"                        
## 2  "$var"             "results for the variables"          
## 3  "$var$coord"       "coord. for the variables"           
## 4  "$var$cor"         "correlations variables - dimensions"
## 5  "$var$cos2"        "cos2 for the variables"             
## 6  "$var$contrib"     "contributions of the variables"     
## 7  "$ind"             "results for the individuals"        
## 8  "$ind$coord"       "coord. for the individuals"         
## 9  "$ind$cos2"        "cos2 for the individuals"           
## 10 "$ind$contrib"     "contributions of the individuals"   
## 11 "$call"            "summary statistics"                 
## 12 "$call$centre"     "mean of the variables"              
## 13 "$call$ecart.type" "standard error of the variables"    
## 14 "$call$row.w"      "weights for the individuals"        
## 15 "$call$col.w"      "weights for the variables"